﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KeywordAuction;

namespace Simulation.Mechanism
{
    public class GFPAuctionMechanism : IAuctionMechanism
    {
        public double GetPaymentValue(int adspotIndex, List<double> clickThroughtRates, List<AdvertiserBidding> bitters)
        {
            if (adspotIndex != -1)
            {
                double rate = clickThroughtRates[adspotIndex];
                var bidsAdspot = bitters.OrderByDescending(p => p.Bid).ToList();
                if (bidsAdspot.Count > adspotIndex)
                {
                    return bidsAdspot[adspotIndex].Bid * rate;
                }
            }
            return 0;
        }
    }
}
